<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of insertmealController
 *
 * @author Administrator
 */
class insertMealController {
    //put your code here
    //public $form;
    
    function index()
    {
        global $config;
        global $zhanggui_meal;

        require_once  ($config['base_dir'] . "/../lib/form.php");
        require_once  ($config['base_dir'] . "/core/baseInfo.php");
        
        $config['title'] = "chike insert meal page";
        $config['keywords'] = "chike meal";
        $config['description'] = "insert meal";
        
        $form = new Form('mealUpload' , '/zhanggui/c.php?a=insertMeal', true, '#header');
        
        $name = new Input('meal_name', '餐名');
        
        $price = new Number('meal_price', '价格');
        
        $img_file = new File("meal_image", '餐品图片');
        
        $taste_flavor = new Choice('taste_flavor', '口味', $zhanggui_meal['taste_flavor'], false, false);
        
        $meal_serial = new Choice('meal_serial', '口味', $zhanggui_meal['meal_serial'], false, false);
        
        $is_promotion = new Choice('is_promotion', '是否促销', $zhanggui_meal['is_promotion'], false, true);
        
        $promotion_begin_date = new Date('promotion_begin', '促销开始时间');
        $promotion_end_date = new Date('promotion_end', '促销结束时间');
        
        $form->add_widget($name)
                ->add_widget($price)
                ->add_widget($img_file)
                ->add_widget($taste_flavor)
                ->add_widget($meal_serial)
                ->add_widget($is_promotion)
                ->add_widget($promotion_begin_date)
                ->add_widget($promotion_end_date)
                ->add_widget(new Submit('submit','','提交'));
        
        if ($form->is_submit()) {
            if (! $form->validate()) return false;
            if (!$file = ( $form->_fields['meal_image']->process_upload())) return false;
            
            //$core = core("user");
            //$core->insert($_POST['name'], $_POST['password'], $file[0]['name']);
            //$core = core("");
            
            print_r($file);

            //return false;
        }
        
        register("mealdoc", $form, "insertMealInfo");
    }
    
    function upload()
    {
        //$form = new Form('mealUpload' , '/zhanggui/c.php?a=insertMeal/upload', false, '#header');
        
        return true;
    }
}

?>
